package com.jdd.modules.sdk.ledcall;

import cn.hutool.core.util.ObjectUtil;
import java.util.Date;
import java.util.Objects;

import javax.annotation.Resource;

import com.jdd.common.constant.EnterAndExportTipsConstant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import com.jdd.common.constant.JddConstant;
import com.jdd.common.constant.LedConstant;
import com.jdd.common.util.DateUtils;
import com.jdd.modules.sdk.LedCallInterface;
import com.jdd.modules.sdk.SdkCallInterface;
import com.jdd.modules.sdkidentifyresultpushlog.entity.DiscountCouponDetail;
import com.jdd.modules.sdkidentifyresultpushlog.entity.ParkOrderInfoVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Objects;

/**
 * author:lcy
 * since 2021/10/26 11:57
 */
@Component
@Lazy
public class SmallFangKongLedCallInterface  extends LedCallInterface {
    @Resource
    private SdkCallInterface sdkCallInterface;
    /**
     * @return
     * @Description 无牌车入口显示播报
     * @author lcy
     * @Date 2021-08-10
     */
    @Override
    public void EntranceUnlicensed(String serialNo) {
        String voice="无牌车,请,扫描入口二维码";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "无牌车,请扫描入口二维码", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "JD停车", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, voice);
    }

    /**
     * @param serialNo
     * @return
     * @Description 军警车入场播报
     * @author lcy
     * @Date 2021-08-10
     */
    @Override
    public void EntranceSpecial(String serialNo, String plateNo) {
        String str = plateNo + ",欢迎光临";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, str, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "欢迎光临", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @return void
     * @author lcy
     * @date 2021/8/12 14:11
     * @Description 免费车过期按照临时车 未启用
     */
    @Override
    public void EntranceParkWhiteOver(String serialNo, String plateNo) {
        String str = "免费车,"+plateNo + ",已过期,按临时车收费";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, str, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo, LedConstant.threeLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "临时车", LedConstant.fourLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @return void
     * @author lcy
     * @date 2021/8/12 14:12
     * @Description 月租车过期禁止进入
     */
    @Override
    public void BanMonthOver(String serialNo, String plateNo, Date endTime,String broadcastInfo) {
        String str = "月租车," + plateNo + ",已过期,请与管理员联系";
        String voice="月租车," + plateNo + ",已过期,请,到,管理处,人工确认";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, str, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "JD停车", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, voice);
    }

    /**
     * @return void
     * @author lcy
     * @date 2021/8/12 14:13
     * @Description 过期N天不可进入
     */
    @Override
    public void BanMonthOverDay(String serialNo, String plateNo, Date endTimes){
        String str = "月租车" + plateNo + ",已过期,请与管理员联系";
        String voice="月租车," + plateNo + ",已过期,请,到,管理处,人工确认";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, str, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "JD停车", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, voice);
    }

    /**
     * @return void
     * @author lcy
     * @date 2021/8/12 14:14
     * @Description 过期N天内可进入
     */
    @Override
    public void EnranceMonthOverCan(String serialNo, String plateNo) {
        String str = "月租车,"+plateNo + ",已过期,按临时车收费";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "月租车"+plateNo + "已过期,按临时车收费", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "欢迎光临", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @param serialNo
     * @return
     * @Description 月租车过期按照临时车收费播报
     * @author lcy
     * @Date 2021-08-10
     */
    @Override
    public void EntranceMonthlyOverdue(String serialNo, String plateNo){
        String str = "月租车,"+plateNo + ",已过期,按临时车收费";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "月租车"+plateNo + "已过期,按临时车收费", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "欢迎光临", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @param serialNo
     * @return
     * @Description 月租车入场播报
     * @author lcy
     * @Date 2021-08-10
     */
    @Override
    public void MonthlyEntrance(String serialNo, String plateNo,String broadcastInfo){
        String str = "月租车," + plateNo + ",欢迎光临";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, broadcastInfo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "欢迎光临", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }
/**
 *
 * @param serialNo
 * @param broadcastInfo
 * @param plateNo
 * @return
 * @author renshangyi
 * @date 2022/3/21
 */
    @Override
    public void outMonthlyEntrance(String serialNo, String plateNo, String broadcastInfo) {
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, broadcastInfo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "一路顺风", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, broadcastInfo);
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
    }

    /**
     * @param serialNo
     * @return
     * @Description 黑名单禁止通行播报
     * @author lcy
     * @Date 2021-08-10
     */
    @Override
    public void EntranceBlacklist(String serialNo, String plateNo) {
        String str =  plateNo + ",此车黑名单,禁止通行";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, str, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "禁止入场", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @param serialNo
     * @return
     * @Description 禁行时间段内播报
     * @author shangyue
     * @Date 2021-08-10
     */
    @Override
    public void JudgeStopDay(String serialNo, String plateNo) {
        String str = "该时段,不允许进入";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "该时段不允许进入", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "禁止入场", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @return void
     * @author lcy
     * @date 2021/8/12 14:18
     * @Description 储值车配置自动开闸
     */
    @Override
    public void EntranceStoredInConfig(String serialNo, String plateNo) {
        String str = "储值车," + plateNo + ",欢迎光临";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "储值车" + plateNo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "欢迎光临", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @return void
     * @author lcy
     * @date 2021/8/12 14:19
     * @Description 储值车配置手动开闸
     */
    @Override
    public void StoredInConfig(String serialNo, String plateNo) {
        String voice="请,到,管理处,人工确认";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "请与管理员联系", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "人工放行", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, voice);
    }

    /**
     * @return void
     * @author lcy
     * @date 2021/8/12 14:19
     * @Description 储值车无配置自动开闸
     */
    @Override
    public void EntranceStoredNoConfig(String serialNo, String plateNo) {
        String str = "储值车," + plateNo + ",欢迎光临";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "储值车" + plateNo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "欢迎光临", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @param serialNo
     * @return
     * @Description 临时车入场播报
     * @author shangyue
     * @Date 2021-08-10
     */
    @Override
    public void TemporaryEntrance(String serialNo, String plateNo){
        String str = "临时车," + plateNo + ",欢迎光临";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "临时车" + plateNo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "欢迎光临", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @return void
     * @author lcy
     * @date 2021/8/12 14:22
     * @Description 临时车入场开闸方式 1 自动开闸
     */
    @Override
    public void TemporaryEntranceInConfig(String serialNo, String plateNo) {
        String str =sdkCallInterface.getOverdueType(plateNo);
        if(ObjectUtil.isEmpty(sdkCallInterface.getOverdueType(plateNo))){
            str=plateNo;
        }
        String strVoice = str +",欢迎光临";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, str, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "欢迎光临", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo,strVoice);
    }

    /**
     * @return void
     * @author lcy
     * @date 2021/8/12 14:22
     * @Description 临时车入场开闸方式 2 确认开闸
     */
    @Override
    public void TemporaryInConfig(String serialNo, String plateNo) {
        String str = sdkCallInterface.getOverdueType(plateNo)+",请,到,管理处,人工确认";
        if(ObjectUtil.isEmpty(sdkCallInterface.getOverdueType(plateNo))){
            str=plateNo+",请,到,管理处,人工确认";
        }
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo+"请到管理处人工确认", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "人工放行", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @param serialNo
     * @return
     * @Description 临时车入场开闸方式 3、不开闸
     * @author shangyue
     * @Date 2021-08-10
     */
    @Override
    public void TemporaryBanEntrance(String serialNo,String plateNo) {
        String str=plateNo+",临时车,禁止通行";
//        String overdueStr = sdkCallInterface.getOverdueType(plateNo);
//        if(ObjectUtil.isEmpty(overdueStr)){
//            str+=plateNo+",临时车,禁止通行";
//        }else{
//            str=overdueStr+",禁止通行";
//        }
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "临时车" + plateNo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "禁止入场", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @param serialNo
     * @return
     * @Description 临时车入场车位已满, 禁止通行播报
     * @author shangyue
     * @Date 2021-08-10
     */
    @Override
    public void TemporaryEntranceParkingFull(String serialNo, String plateNo) {
        String str=plateNo+",临时车,车位已满";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "临时车" + plateNo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "车位已满", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * 临时车位已满 确认开闸
     *
     * @param serialNo
     * @param plateNo
     * @return void
     * @author jdd孙庆伟
     * @date 2021/8/31 14:58:26
     * @version 1.0
     */
    @Override
    public void TemporaryEntranceFullConfirmOpened(String serialNo, String plateNo) {
        String str = plateNo+",车位已满,请,到,管理处,人工确认";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo+"车位已满,请到管理处人工确认", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "人工放行", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    //---------------------------出场------------------------------

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 无牌车出场
     */
    @Override
    public void OutUnlicensed(String serialNo) {
        String str = "无牌车,请,扫描,出口,二维码";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "无牌车,请扫描出口二维码", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "智慧出行", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 特殊车出场
     */
    @Override
    public void OutSpecial(String serialNo, String plateNo) {
        String str = "一路顺风";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "军警车" + plateNo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, str, LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 免费车出场
     */
    @Override
    public void OutParkWhite(String serialNo, String plateNo) {
        String str = plateNo + ",一路顺风";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "免费车" + plateNo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "一路顺风", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);

    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 月租车出场 未使用
     */
    @Override
    public void OutMonthly(String serialNo, String plateNo) {
        String str = plateNo + ",一路顺风";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "月租车" + plateNo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "一路顺风", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);

    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 调用计费规则异常处理
     */
    @Override
    public void OutAbnormal(String serialNo, String plateNo) {
        String str = "请,到,管理处,人工确认";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo + "请到管理处人工确认", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "禁止出场", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 无异常 无入场记录不抬杆
     */
    @Override
    public void OutAbnormalBan(String serialNo, String plateNo) {
        String voice=plateNo+",此车,入场,记录,无效,请,到,管理处,人工确认";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo + "无入场记录", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "禁止出场", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, voice);

    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 无异常 无入场记录免费放行
     */
    @Override
    public void OutAbnormalCan(String serialNo, String plateNo) {
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo + "无入场记录,免费放行", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "一路顺风", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, plateNo + ",无,入场,记录,免费放行");

    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 停车费已支付处理
     */
    @Override
    public void OutPayParkingFee(String serialNo, String plateNo) {
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo + "已缴费", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "一路顺风", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, plateNo + "已缴费,一路顺风");
    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 使用免费时长券/全免券/小时券的订单
     */
    @Override
    public void OutDiscount(String serialNo, String plateNo, DiscountCouponDetail discountCouponDetail) {
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "一路顺风", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, plateNo + ",一路顺风");
    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 储值车无入场纪录 未启用
     */
    @Override
    public void OutStoredNoInLogs(String serialNo, String plateNo) {
        String voice=plateNo+",此车,入场,记录,无效,请,到,管理处,人工确认";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "未找到车辆入场记录", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo, LedConstant.threeLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "无入场纪录", LedConstant.fourLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, voice);
    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 储值车缴费出场
     */
    @Override
    public void OutStoredPayFee(String serialNo, String plateNo, Integer unpayFee, Integer remaining, ParkOrderInfoVO parkOrderInfoVO) {
        String remainingStr = remaining+"";
        String str = "储值车" + plateNo + ",停车" + DateUtils.qianyiTurnDayHourMinuteString(String.valueOf(parkOrderInfoVO.getChargeDuration()))
                + ",金额" + unpayFee + "元" + ",剩余金额" + remainingStr + "元";
        String fourLineStr = "收费" + unpayFee + "元";
        String voice = "储值车," + plateNo + ",停车," + formatTime(Objects.requireNonNull(DateUtils.qianyiTurnDayHourMinuteString(String.valueOf(parkOrderInfoVO.getChargeDuration()))))
                + ",金额," +SmallFangKongLedCallInterface.int2chineseNum( unpayFee+"",false) + ",元" + ",剩余,金额," + SmallFangKongLedCallInterface.int2chineseNum(remainingStr,false) + "元";
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, str, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "小心慢行", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, voice);
    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 调用计费规则异常处理
     */
    @Override
    public void OutStoredChargeAbnormal(String serialNo, String plateNo) {
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo + "请到管理处人工确认", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "禁止出场", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, "请,到,管理处,人工确认");
    }

    /**
     * @author lcy
     * @date 2021/8/13
     * @Description 播报收费信息
     */
    @Override
    public void OutShowFee(String serialNo, String plateNo, ParkOrderInfoVO parkOrderInfo) {
        String voice = parkOrderInfo.getPlateNo() + ",金额,"  +SmallFangKongLedCallInterface.int2chineseNum( Integer.parseInt(parkOrderInfo.getChargeUnpaid()) / 100+"",false)+  ",元" +
                ",停车," + formatTime(Objects.requireNonNull(DateUtils.qianyiTurnDayHourMinuteString(String.valueOf(parkOrderInfo.getChargeDuration()))));
        String str = parkOrderInfo.getPlateNo() + ",金额" + Integer.parseInt(parkOrderInfo.getChargeUnpaid()) / 100 + "元" +
                ",停车" + DateUtils.qianyiTurnDayHourMinuteString(String.valueOf(parkOrderInfo.getChargeDuration()));
        String chargeStr = "收费" + Integer.parseInt(parkOrderInfo.getChargeUnpaid()) / 100 + "元";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, str, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "小心慢行", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, voice);
    }

    @Override
    public void RefuseCarEnter(String serialNo, String plateNo) {
        String str="请,到,管理处,人工确认";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo + "请到管理处人工确认", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "JD停车", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * 重复入场
     */
    @Override
    public void repeatRecognitionConfirmOpened(String serialNo, String plateNo) {
        String str = plateNo + "重复入场";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, str, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "人工放行", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
    }

    /**
     * 月租车出场 播报收费信息
     * @param serialNo
     * @param plateNo
     * @param broadcastInfo
     * @return
     * @author renshangyi
     * @date 2022/4/1
     */
    @Override
    public void OutMonthlyShowFee(String serialNo, String plateNo, String broadcastInfo) {
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, broadcastInfo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "JD停车", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, broadcastInfo);
    }

    @Override
    public void EntranceWhite(String serialNo, String plateNo) {
        String str = "免费车," + plateNo + ",欢迎光临";
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "免费车" + plateNo, LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "欢迎光临", LedConstant.twoLine);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, str);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
    }

    /*** 功能描述: 播报钱数有问题，比如190，播报一百九零，需要手动转换一下
     * @Author: lcy
     * @Date: 2021/10/21
     * @param stringMoney 字符串的钱数
     * @param isToChinese 是否需要转换，有的不需要因为单位是元
     */
    public static String int2chineseNum(String stringMoney,boolean isToChinese) {
        if (StringUtils.isBlank(stringMoney)) {
            return "";
        }
        //钱数只有十位正常
        if (stringMoney.length() < 2) {
            return stringMoney;
        }
        Integer src = Integer.parseInt(stringMoney);
        //传来的参数有时单位是元
        if (isToChinese) {
            src = src / 100;
        }
        final String[] num = {"零", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
        final String[] unit = {"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"};
        String dst = "";
        int count = 0;
        while (src > 0) {
            dst = (num[src % 10] + unit[count]) + dst;
            src = src / 10;
            count++;
        }
        return dst.replaceAll("零[千百十]", "零").replaceAll("零+万", "万")
                .replaceAll("零+亿", "亿").replaceAll("亿万", "亿零")
                .replaceAll("零+", "零").replaceAll("零$", "");
    }
    /*** 功能描述: 返回处理后的时间，带逗号
     * @param parkTime  DateUtils.qianyiTurnDayHourMinuteString处理的时刻
     * @Author: lcy
     * @Date: 2021/10/28
     */
    public String formatTime(String parkTime){
        String dayTime="";
        String hourTime="";
        String minTime="";
        StringBuilder builder = new StringBuilder();
        if(parkTime.contains("天")) {
            dayTime = parkTime.substring(0, parkTime.indexOf("天"));
        }
        if(parkTime.contains("时")) {
            if(parkTime.contains("天")){
                hourTime= parkTime.substring(parkTime.indexOf("天")+1, parkTime.indexOf("小"));
            }else{
                hourTime= parkTime.substring(0,parkTime.indexOf("小"));
            }
        }
        if(parkTime.contains("分")){
            if(parkTime.contains("天")&&parkTime.contains("时")){
                minTime=parkTime.substring(parkTime.indexOf("时")+1,parkTime.indexOf("分"));
            }
            if(parkTime.contains("天")&&!parkTime.contains("时")){
                minTime=parkTime.substring(parkTime.indexOf("天")+1,parkTime.indexOf("分"));
            }
            if(!parkTime.contains("天")&&parkTime.contains("时")){
                minTime=parkTime.substring(parkTime.indexOf("时")+1,parkTime.indexOf("分"));
            }
            if(!parkTime.contains("天")&&!parkTime.contains("时")){
                minTime=parkTime.substring(0,parkTime.indexOf("分"));
            }
        }
        if(StringUtils.isNotEmpty(dayTime)){
            builder.append(int2chineseNum(dayTime,false)+",天,");
        }
        if(StringUtils.isNotEmpty(hourTime)){
            builder.append(int2chineseNum(hourTime,false)+",小时,");
        }
        if(StringUtils.isNotEmpty(minTime)){
            builder.append(int2chineseNum(minTime,false)+",分钟,");
        }
        return builder.toString();
    }
    /*** 功能描述: 场内码支付成功得，加上去缴费成功
     * @Author: lcy
     * @Date: 2022/1/19
     */
    @Override
    public void FieldFee(String serialNo, String plateNo) {
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo + "缴费成功", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "小心慢行", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, plateNo + "缴费成功,一路顺风");
    }

    /**
     * 临时车不收费出场
     * @param serialNo
     * @param plateNo
     */
    @Override
    public void FieldFeeOut(String serialNo, String plateNo) {
        sdkCallInterface.SdkUnfoldAll(JddConstant.SdkOpenGateLog.SWICH_TYPE_ONE, serialNo, plateNo);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, plateNo + "一路顺风", LedConstant.oneLine);
        sdkCallInterface.Sdk485TestContentCommunicationAll(serialNo, "小心慢行", LedConstant.twoLine);
        sdkCallInterface.Sdk485LedGreenToRed(serialNo,LedConstant.greenToRedTime);
        sdkCallInterface.Sdk485VoiceCommunicationAll(serialNo, plateNo+",一路顺风");
    }
}
